// 创建vuex实列对象
import { createStore, createLogger } from 'vuex'
import user from './modules/user'
import cart from './modules/cart'
import category from './modules/category'
// 引入插件，持久化
import createPersistedState from 'vuex-persistedstate'// 默认是本地存储
// import Cookies from 'js-cookie'
export default createStore({
  state: () => ({}),
  mutations: {
  },
  actions: {
  },
  modules: {
    user,
    cart,
    category
  },
  plugins: [createPersistedState({
    key: 'rabbit',
    paths: ['user', 'cart']
  }),

  // Cookies
  // plugins: [createPersistedState({
  //   storage: {
  //     getItem: key => {
  //       console.log('取值')
  //       console.log(Cookies.get(key))
  //     },
  //     setItem: (key, value) => {
  //       console.log('改值', value)
  //       Cookies.set(key, value)
  //     },
  //     removeItem: key => Cookies.remove(key)
  //   },
  //   key: 'kxs',
  //   paths: ['user', 'cart']
  // }),
  createLogger()// 每次提交mutation函数都会在浏览器打印区域 打印出本次mutation提交的关键信息
  ]
})
